<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE >
<html>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript">
	$(function() {
		$('#verifyCode').focusout(function() {
			var verifyCode=$("#verifyCode").value()
			$.ajax({
				url : 'index/validateVerifyCode',
				type : 'POST',
				data : {"verifyCode" :verifyCode},
				dataType : 'json',
				success : function(data) {
					if(data.success){
						$('#result').html("验证码正确");
					}else{
						$('#verifyCode').focus();
						$('#result').html("验证码正确");
					}
				}
			});
		});
		$('#startLogin').click(function(){
			$.ajax({
				url : 'index/login',
				type : 'POST',
				data : $("#_loginForm").serialize(),
				dataType : 'json',
				success : function(data) {
					if(data.success){
						$('#result').html(data.message);
					}else{
						$('#result').html(data.message);
					}
				}
			});
		})
		$("#verifyCode").focus();
	})
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="login" method="post" id="loginForm">
		<input type="text" name="phoneOrEmail"> <input type="text"
			name="password"> <input ]type="text" id="verifyCode"
			name="verifyCode"><img src="index/getVerifyCode">
			<div id="result"></div>
			<button id="startLogin" >登录</button>
	</form>
</body>
</html>